<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.2.1.min.js"></script>
    <style>
        div{
            border: 1px solid  black;
        }
        #menuDiv{
            width: 150px;
        }

        .head{
            height: 25px;
            background-color: green;
            text-align: center;
        }

        .body{
            height: 100px;
            background-color: yellow;
            text-align: center;
            display: none;
        }
    </style>
    <script>
        var divObj;
        $(function () {
            divObj = $("#blackDiv");
            var headArray=$(".head");
            for(var i=0;i<headArray.length;i++){
                $(headArray[i]).click(function () {
                    divObj[0].style.display="none";
                    this.nextElementSibling.style.display="block";
                    divObj=$(this.nextElementSibling);
                });
            }
        });
    </script>
</head>
<body>
    <div id="menuDiv">
        <div class="head">好友</div>
        <div class="body">
                任我行<br>
                陈近男<br>
                风际中
        </div>
        <div class="head">亲人</div>
        <div class="body">
            令狐冲<br>
            韦小宝<br>
            张无忌
        </div>
        <div class="head">好友</div>
        <div class="body" style="display: block" id="blackDiv">
            海大富<br>
            林平之<br>
            风际中
        </div>

    </div>
</body>
</html>